#ifndef PLAYER_SIMULATOR_H
#define PLAYER_SIMULATOR_H

#include "player_structures.h"
#include "countries.h"
#include "names.h"
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <random>

class PlayerSimulator {
private:
    std::vector<Player> players;
    std::mt19937 rng;
    
    // Helper functions for random generation
    int getRandomSkill(int baseScore = 70);
    std::string generateNameByCountry(const std::string& countryCode);
    std::string getCountryByWeight();
    double calculateOverallScore(const GamingSkills& skills);
    void generateProfessionalStats(Player& player);
    void calculateRankings();
    
public:
    PlayerSimulator();
    
    // Core functionality
    void generatePlayers(int count);
    void displayPlayer(int playerId);
    void findPlayersByScoreRange(double minScore, double maxScore);
    void findPlayersByRankingRange(int minRank, int maxRank);
    void comparePlayers(int playerId1, int playerId2);
    void showCountryRankings(const std::string& country);
    void listAvailableCountries();
    void displayCountryRankings();
    
    // New function for player ability changes
    void updatePlayerAbilities();
    
    // Function to set external factor for a player
    void setPlayerExternalFactor(int playerId, double factor);
    
    // Friend management functions
    bool addFriend(int playerId, int friendId);
    bool removeFriend(int playerId, int friendId);
    void displayFriends(int playerId);
    
    // Utility functions
    void resetAndGenerate(int playerCount);
    int getPlayerCount() const { return players.size(); }
    const Player& getPlayer(int id) const;
    
    // Menu and interaction
    void showMainMenu();
    bool handleMenuChoice(int choice);
};

#endif // PLAYER_SIMULATOR_H
